SQL EditorThe SQL editor allows to send queries directly to the connected CData Virtuality Server.
The upper pane of the editor allows for entering queries; in the lower pane results of the query are displayed.
button, or alternatively + on the keyboard. If only the find functionality is desired, + can be used instead.
button, or alternatively ++ on the keyboard.+++FROM, JOIN, CALL, EXEC, and EXECUTE, as well as after a period if the name of a schema is detected.
(shift right) or + (shift left)++++
+
+ / +
+
+
The SQL editor allows to save the current script to a file, as well as to open a saved script (Open script file
and Save script file
buttons). If an existing file is open in an SQL Editor, it can be saved under a different name with the Save as
button. Please note, only the UTF-8 character encoding is supported.
To issue a query type it into the SQL editor.
button. Please separate the queries with the statement separator (can be configured in the Preferences). The default statement separator is a double semicolon (;;).
. If nothing is selected, the query under the cursor, as delimited by the statement separator, will be executed. Alternatively, the keyboard shortcut + can be used to the same effect.
button.
button. This will open the Google Analytics Query Builder, which will automatically insert a SQL Query in the editor that corresponds to the parameters given by the user.
You can limit the number of results by setting the Limit Rows value in the filter line. You can reuse one of the previously entered queries by selecting it in the quick history popup or in the Advanced History Dialog
.
The SQL Editor includes wizards to facilitate the generation of queries that retrieve data from CSV or XML files, either local or remote (from a web service). To open the corresponding wizard, simply click on the CSV query builder
or the XML query builder
buttons, located in the toolbar. Please note that these wizards require a data source of type "File" or "Web Service" to be configured in the Server.
The SQL editor is able to build the execution plan for the current query without executing it. To use it, simply press the Show query plan
button. The current query is either the selected text or the query under the cursor if nothing selected, as delimited by the statement separator.
Please note that the SQL Editor result pane displays the preview of the value limited by 250 characters. A tooltip can be displayed on a cell that shows first 32 Kilobytes of data. It is activated by a double click or on hover, depending on the configured CData Virtuality Studio preferences.
CData Virtuality Server supports, among others, select queries, insert queries, stored procedure language and create / alter statements. For a full list of supported SQL features please see the reference manual.
Following are examples for valid SQL editor queries.
;; (double semicolon). It can be changed in the Preferences.
BEGIN
SELECT * FROM adventureworks.address;
END
BEGIN
call SYSADMIN.createOptimization('adventureworks.contact');
END
BEGIN
DECLARE date startdate='2012-01-01';
DECLARE date enddate='2012-02-04';
DECLARE date idate;
idate=startdate;
CREATE LOCAL TEMPORARY TABLE #x(xdate date);
WHILE (idate<=enddate)
BEGIN
INSERT INTO #x(xdate) VALUES (idate);
idate=timestampadd(SQL_TSI_DAY,1,idate);
END
SELECT * from #x;
END
Stored procedures
CREATE VIRTUAL PROCEDURE views.dateaxis(IN startdate date,IN enddate date) returns (xdate date) as BEGIN DECLARE date idate; idate=startdate; CREATE LOCAL TEMPORARY TABLE #x(xdate date); WHILE (idate<=enddate) BEGIN INSERT INTO #x(xdate) VALUES (idate); idate=timestampadd(SQL_TSI_DAY,1,idate); END SELECT * from #x; END;; ALTER PROCEDURE views.dateaxis() returns (xdate date) as BEGIN SELECT current_date; END;;Views
CREATE VIEW views.countryregion AS SELECT * FROM adventureworks.countryregion;; CREATE VIEW views.creditcard AS SELECT * FROM adventureworks.creditcard;;
CREATE VIEW views.countryregion AS SELECT * FROM adventureworks.countryregion;; CREATE VIEW views.creditcard AS SELECT * FROM adventureworks.creditcard;; ALTER VIEW views.creditcard AS SELECT * from (SELECT * FROM adventureworks.creditcard) a;;
CREATE VIEW views.countryregion AS SELECT * FROM adventureworks.countryregion; DROP VIEW views.countryregion;Select
Select * from adventureworks.address;;Create table
create table dwh.testtable(a integer);; drop table dwh.testtable;;Insert into / Select into
create table dwh.testtable(a integer);; insert into dwh.testtable select 1;; select 1 into dwh.testtable;; select * from dwh.testtable;Explain
explain SELECT * FROM adventureworks_part_one.addresstype